/*     */ package com.qmsk.business.store.goodsTypeSml.controller;
/*     */ 
/*     */ import com.qmsk.business.store.goodsTypeSml.dao.GoodsTypeSmlDao;
/*     */ import com.utils.basic.MapUtils;
/*     */ import com.utils.gson.in.ParserDataSetJson;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.io.IOException;
/*     */ import java.util.HashMap;
/*     */ import java.util.Map;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/goodsTypeSml"})
/*     */ public class GoodsTypeSmlController
/*     */ {
/*  31 */   private static final Logger logger = Logger.getLogger(GoodsTypeSmlController.class);
/*     */ 
/*     */   @Autowired
/*     */   private GoodsTypeSmlDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/opt/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOptShopId(HttpServletRequest request, HttpServletResponse response, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  50 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  52 */       Map params = new HashMap();
/*  53 */       MapUtils.addToMap(params, "id", RequestUtils.getLong(request, "id"));
/*     */ 
/*  55 */       MapUtils.addPercentToMap(params, "name", 
/*  56 */         RequestUtils.getString(request, "name"));
/*  57 */       MapUtils.addPercentToMap(params, "code", 
/*  58 */         RequestUtils.getString(request, "code"));
/*     */ 
/*  60 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  61 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     }
/*     */     catch (Exception e) {
/*  64 */       logger.error(e);
/*     */ 
/*  66 */       ResponseUtils.setErrorMsgResponse(
/*  67 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/MId/{mId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfMedId(HttpServletRequest request, HttpServletResponse response, @PathVariable("mId") Long mId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  76 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  78 */       Map params = new HashMap();
/*  79 */       params.put("medId", mId);
/*     */ 
/*  81 */       GsonEbRst gsonEbRst = this.dao.getGsonOfAll(params, nPageIdx, nPageSize);
/*  82 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     }
/*     */     catch (Exception e) {
/*  85 */       logger.error(e);
/*     */ 
/*  87 */       ResponseUtils.setErrorMsgResponse(
/*  88 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/id/{id}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListOfId(HttpServletRequest request, HttpServletResponse response, @PathVariable("id") Long id)
/*     */   {
/*     */     try {
/*  96 */       Map params = new HashMap();
/*  97 */       MapUtils.addToMap(params, "id", id);
/*     */ 
/*  99 */       GsonEbRst gsonEbRst = this.dao.getGsonOfId(params);
/* 100 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (Exception e) {
/* 102 */       logger.error(e);
/* 103 */       ResponseUtils.setErrorMsgResponse(
/* 104 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException
/*     */   {
/*     */     try
/*     */     {
/* 124 */       int nResult = 0;
/* 125 */       String sData = RequestUtils.getStringOfData(request);
/* 126 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/*     */ 
/* 128 */       nResult = this.dao.applyUpdates(p);
/*     */ 
/* 130 */       if (nResult > 0)
/* 131 */         DbConnection.commit();
/*     */       else {
/* 133 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 136 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 137 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 138 */         response);
/*     */     } catch (Exception e) {
/* 140 */       DbConnection.rollback();
/* 141 */       logger.error(e);
/* 142 */       ResponseUtils.setErrorMsgResponse(
/* 143 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 144 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 158 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 160 */       String[] strParams = id.split(",");
/*     */ 
/* 162 */       int nResult = this.dao.deleteParams(strParams);
/*     */ 
/* 164 */       if (nResult > 0)
/* 165 */         DbConnection.commit();
/*     */       else {
/* 167 */         DbConnection.rollback();
/*     */       }
/*     */ 
/* 170 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 171 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 172 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 175 */       DbConnection.rollback();
/* 176 */       logger.error(e);
/* 177 */       ResponseUtils.setErrorMsgResponse(
/* 178 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 179 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit/shopId/{shopId}"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/*     */     try
/*     */     {
/* 197 */       int nResult = 0;
/* 198 */       String sData = RequestUtils.getStringOfData(request);
/* 199 */       ParserDataSetJson p = ParserDataSetJson.fromString(sData);
/* 200 */       if (p != null) {
/* 201 */         nResult = this.dao.applyUpdates(p);
/*     */       }
/* 203 */       if (nResult > 0)
/* 204 */         DbConnection.commit();
/*     */       else {
/* 206 */         DbConnection.rollback();
/*     */       }
/* 208 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 209 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 210 */         response);
/*     */     } catch (Exception e) {
/* 212 */       logger.error(e);
/* 213 */       DbConnection.rollback();
/* 214 */       ResponseUtils.setErrorMsgResponse(
/* 215 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 216 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.store.goodsTypeSml.controller.GoodsTypeSmlController
 * JD-Core Version:    0.5.3
 */